﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Odelle.Utils
{
    public class CsNameSplitter
    {
        public string Split(string text)
        {
            return  this.Split(text, " ",true).Trim();
        }

        public string Split(string text,string delimiter, bool BeginWithCapital)
        {
            const  string uppers = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            string result = "";

            if (text == "" || text=="ID")
            {
                result = text;
            }
            else
            {
                if (BeginWithCapital)
                {
                    result = text.Substring(0, 1).ToUpper();
                }
                else
                {
                    result = text.Substring(0, 1);
                }

                for (int i = 1; i < text.Length; ++i)
                {
                    string cha=text.Substring(i,1);

                    if (uppers.Contains(cha))
                    {
                        result = result + delimiter + cha;
                    }
                    else
                    {
                        result = result +cha;
                    }
                }
            }

            return result;
        }
    }
}
